﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SkyBase
{
    class HealthOverlay:Overlay
    {

        private Texture2D fullTex;
        private GameObject player;
        private float percentage = 1;

        public HealthOverlay(GameObject player)
            : base(Storage.getTexture("HealthBarEmpty"), "HealthBar", true)
        {
            fullTex = Storage.getTexture("HealthBarFull");
            this.player = player;
            layer = 0.3f;
        }

        public override void Update(GameTime gameTime)
        {
            percentage = (player as Player).Health / (player as Player).maxHealth;
            //Debugger.debug(percentage.ToString() + "%, " + (player as Player).Health.ToString());
        }

        public override void Draw(SpriteBatch spriteBatch, Vector2 cameraPos)
        {

            Rectangle tempBounds = bounds;
            tempBounds.X = (int)cameraPos.X;
            tempBounds.Y = (int)cameraPos.Y;
           // spriteBatch.Draw(background, tempBounds, new Rectangle(0, 0, (int)background.Width, (int)background.Height), Color.White, 0, Vector2.Zero, SpriteEffects.None, layer - 0.1f);
            spriteBatch.Draw(fullTex, tempBounds, new Rectangle(0, 0, (int)(fullTex.Width * percentage), fullTex.Height), Color.White * alpha, 0, new Vector2(0, 0), SpriteEffects.None, layer - 0.1f);

            base.Draw(spriteBatch, cameraPos);
        }
    }
}
